@extends('layout/default')

@section('content')
<div class="container ">
<form action="{{url('train/join')}}" method="POST" >
    <input type="hidden" name="TBTrainID" value="{{$entry->TID}}">
    <input type="hidden" name="_token" value="{{csrf_token()}}">
    <div clas="row ">

        <div class="col-xs-12 ">
            <img class="img-thumbnail" src="{{asset(isset($entry->TTumb)?$entry->TTumb:'images/default.jpg')}}" style="width: 100%;margin: 1em auto">
        </div>


        @if($entry->TTitle)
            <div class="col-xs-12" style="margin-top: 1em" >
                {{$entry->TTitle}}
            </div>
        @endif

        @if($entry->TBeginAt)
              <div class="col-xs-12" style="margin-top: 1em" >
                  时间：{{date('Y年m月d日',strtotime($entry->TBeginAt))}}——{{date('Y年m月d日',strtotime($entry->TEndAt))}}
              </div>
        @endif
        @if($entry->TCoach)
                <div class="col-xs-12" style="margin-top: 1em" >
                    教练介绍：{{$entry->TCoach}}
                </div>
        @endif
        @if($entry->TQty)
              <div class="col-xs-12" style="margin-top: 1em" >
                  总课时：{{$entry->TQty}}
              </div>
        @endif
      @if($entry->TCourse)
              <div class="col-xs-12" style="margin-top: 1em" >
                  课程安排：{{$entry->TCourse}}
              </div>
        @endif


        @if($entry->TCost)
                <div class="col-xs-12" style="margin-top: 1em" >
                    课时单价：{{$entry->TCost}}
                </div>
        @endif




        @if($entry->TContent)
                <div class="col-xs-12" style="margin-top: 1em" >
                    内容：{{$entry->TContent}}
                </div>
        @endif
        @if($entry->TMemo)
                <div class="col-xs-12" style="margin-top: 1em" >
                    其他说明：{{$entry->TMemo}}
                </div>
        @endif
        @if($join)
                @if($join->TBQtyRemain)
                    <div class="col-xs-12" style="margin-top: 1em" >
                         我的剩余课时：{{$join->TBQtyRemain}}
                    </div>
                @endif
                @if($join->TBQty)
                    <div class="col-xs-12" style="margin-top: 1em" >
                    我的课时消费：{{$join->TBQty.'课时'.$join->TBPrice.'元'}}
                    </div>
                @endif

        @else
            @if($entry->TQty1||$entry->TQty2||$entry->TQty3)
                <div class="col-xs-12" style="margin-top: 1em" >

                     <span class="pull-left" style="margin-top:0.3em">课时：</span>
                        <div class="pull-left">
                            <select class="form-control col-xs-5" name="TBQty">
                              @if($entry->TQty1)
                                <option value="{{$entry->TQty1}}" >{{$entry->TQty1}}课时{{$entry->TPrice1}}元</option>
                              @endif
                              @if($entry->TQty2)
                                  <option value="{{$entry->TQty2}}" >{{$entry->TQty2}}课时{{$entry->TPrice2}}元</option>
                              @endif
                              @if($entry->TQty3)
                                <option value="{{$entry->TQty3}}">{{$entry->TQty3}}课时{{$entry->TPrice3}}元</option>
                              @endif
                              @if($entry->TQty4)
                                <option value="{{$entry->TQty4}}">{{$entry->TQty4}}课时{{$entry->TPrice4}}元</option>
                              @endif
                            </select>
                        </div>



                </div>
            @endif
            <div class="col-xs-12" style="margin-top: 1em" >
                        <div class="form-group">
                            <label for="exampleInputEmail1">姓名</label>
                            <input type="text" class="form-control" id="TBName" name="TBName" placeholder="姓名" required>
                         </div>
                    </div>
                    <div class="col-xs-12" style="margin-top: 1em" >
                        <div class="form-group">
                            <label for="exampleInputEmail1">电话</label>
                            <input type="text" class="form-control" id="TBMobile" name="TBMobile" placeholder="电话" required>
                         </div>
                    </div>
                    <div class="col-xs-12" style="margin-top: 1em" >
                        <div class="form-group">
                            <label for="exampleInputEmail1">年龄</label>
                            <input type="text" class="form-control" id="TBAge" name="TBAge" placeholder="年龄" required>
                         </div>
                    </div>
                    <div class="col-xs-12" style="margin-top: 1em" >
                        <div class="form-group">
                          <label for="TBSex">性别&nbsp;&nbsp;</label><br/>
                          <input type="radio" name="TBSex" id="TBSex" value="0" checked>&nbsp;男
                          <input type="radio" name="TBSex" value="1" {{(isset($entry->TBSex)?$entry->TBSex:'')==1?'checked':''}}>&nbsp;女
                       </div>
                    </div>
        @endif


    </div>

    <div class="row">
        <div class="col-xs-12 "style="margin-top: 3em;padding: 15px">
            <input class="btn btn-primary col-xs-12" id="join" value="立即报名" style="width:100%;height: 3em" type="submit" {{isset($join)?'disabled':''}}>
        </div>

    </div>

</form>

</div>

@endsection
@section('scripts')
    <script>
    $(function(){
      {{--var action='{{$relative?1:0}}'; //报名状态--}}
      {{--$('#join').click(function(){--}}
            {{--$.ajax({--}}
                {{--url:'{{url('train/join')}}',--}}
                {{--type:'POST',--}}
                {{--data:{TrainID:'{{$entry->TID}}',_token:'{{csrf_token()}}',action:1-action},--}}
                {{--dataType:'json',--}}
                {{--success:function(data){--}}
                    {{--action=1-action;--}}
                    {{--if(action){--}}
                        {{--$('#join').val('取消报名')--}}
                    {{--}else{--}}
                        {{--$('#join').val('立即报名')--}}
                    {{--}--}}

                {{--}--}}
            {{--})--}}
        {{--})--}}





    })

    </script>
@endsection
